﻿/*  
    Copyright (C) <2007-2013>  <Kay Diefenthal>

    ArgusTv.UI.MediaCenter is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ArgusTv.UI.MediaCenter is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ArgusTv.UI.MediaCenter.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using Microsoft.MediaCenter.UI;

namespace ArgusTV.UI.MediaCenter.Views
{
    public class LiveView : ModelItem
    {
        private Choice _channels;
        private Choice _groups;
        private String _subtitle;
        private ArrayListDataSet _informations;
        public String SubTitle
        {
            get { return _subtitle; }
            set
            {
                if(_subtitle!=value)
                {
                    _subtitle = value;
                    FirePropertyChanged("SubTitle");
                }
            }
        }
        public virtual Choice Groups
        {
            get { return _groups; }
            set
            {
                if (_groups != value)
                {
                    if (_groups != null)
                    {
                        _groups.ChosenChanged -= OnGroupChanged;
                    }
                    _groups = value;
                    if (_groups != null)
                    {
                        _groups.ChosenChanged += OnGroupChanged;
                    }
                    OnGroupChanged(_groups, EventArgs.Empty);
                    FirePropertyChanged("Groups");
                }
            }
        }
        public virtual Choice Channels
        {
            get { return _channels; }
            set
            {
                if (_channels != value)
                {
                    if (_channels != null)
                    { _channels.ChosenChanged -= OnChannelChanged; }
                    _channels = value;
                    if (_channels != null)
                    { _channels.ChosenChanged += OnChannelChanged; }
                    OnChannelChanged(_channels, EventArgs.Empty);
                    FirePropertyChanged("Channels");
                }
            }
        }
        public virtual ArrayListDataSet Informations
        {
            get { return _informations; }
            set
            {
                if (_informations != value)
                {
                    _informations = value; FirePropertyChanged("Informations");
                }
            }
        }
        public event EventHandler GroupChanged;
        public event EventHandler ChannelChanged;
        public void PreviousChannel()
        {
            if (Channels.HasPreviousValue)
            {
                Channels.PreviousValue(true);
            }
        }
        public void NextChannel()
        {
            if (Channels.HasNextValue)
            {
                Channels.NextValue(true);
            }
        }
        public void PreviousChannelGroup()
        {
            if (Groups.HasPreviousValue)
            {
                Groups.PreviousValue(true);
            }
        }
        public void NextChannelGroup()
        {
            if (Groups.HasNextValue)
            {
                Groups.NextValue(true);
            }
        }
        protected virtual void OnGroupChanged(object sender, EventArgs args)
        {
            if (GroupChanged != null)
                GroupChanged(this, EventArgs.Empty);
        }
        protected virtual void OnChannelChanged(object sender, EventArgs args)
        {
            if (ChannelChanged != null)
                ChannelChanged(this, EventArgs.Empty);
        }
    }
}